package com.pan.api.utils;


/**
 * json basic structure:
 * {
 *     "key": "value",
 *     "key": {
 *         "k": "v",
 *         "k": [{"k":"v"},{"k":"v"}]
 *     }
 * }
 *
 * 1.output json:
 * key -> Field Name
 * value -> Field type
 *
 * 2.output json structure of the generic types:
 * key -> Field Name
 * value ->
 * {
 *     "type": "Field Type",
 *     "generics":{
 *          "Generic Name": {
 *              key: value,
 *              key: value
 *          },
 *          "Generic Name": {
 *              key: value,
 *              key: value
 *          }
 *      }
 * }
 *
 * example:
 * class com.xxx.Student{
 *     int age;
 *     String name;
 *     public Student(int age, String name){this.age=age;this.name=name;}
 * }
 * class ExampleClass{ BiFunction<String,Integer,Student> create = (name, age)->new Student(); }
 *
 * output json of the ExampleClass:
 * {
 *      "create" : {
 *          "type": "java.util.function.BiFunction<java.lang.String,java.lang.Integer,com.xxx.Student>",
 *          "generics":{
 *              "java.lang.String": "base type",
 *              "java.lang.Integer": "base type",
 *              "com.xxx.Student": {
 *                  "age": "int",
 *                  "name": "java.lang.String"
 *              }
 *          }
 *      }
 * }
 *
 * 3.output json of array:
 *
 * key -> Field Name[]
 * value -> Field Type
 *
 */

public interface PanJsonConvertUtil {
    default String convertToJson(Class<?> tar){
        return PanJsonConvertUtilAdapter.INSTANCE.convertToJson(tar);
    }

    default String jsonFormat(String json){
        return PanJsonConvertUtilAdapter.INSTANCE.jsonFormat(json);
    }

}
